package com.medisign.sign.log.web;

import com.medisign.sign.log.service.ISignLogService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/sign/log")
@RequiredArgsConstructor
@RestController
public class SignLogController {

    private final ISignLogService signLogService;

    @RequestMapping("/run")
    public String doRun() {
        signLogService.run();
        return "success";
    }

    @RequestMapping("/stop")
    public String stop() {
        signLogService.stop();
        return "success";
    }

    @RequestMapping("/getRedisId")
    public Long getRedisId() {
        Long id = signLogService.getRedisId();
        return id;
    }

    @RequestMapping("/setRedisId")
    public String getRedisId(@RequestParam Long redisId) {
        signLogService.setRedisId(redisId);
        return "success";
    }

    @RequestMapping("/clearRedisId")
    public Long clearRedisId() {
        Long id = signLogService.clearRedisId();
        return id;
    }

    @RequestMapping("/clearLock")
    public String clearLock() {
        signLogService.clearLock();
        return "success";
    }

    @RequestMapping("/getCurrentLogFileName")
    public String getCurrentLogFileName() {
        String name = signLogService.getCurrentLogFileName();
        return name;
    }

    @RequestMapping("/setCurrentLogFileName")
    public String setCurrentLogFileName(@RequestParam String fileName) {
        signLogService.setCurrentLogFileName(fileName);
        return "success";
    }

    @RequestMapping("/clearCurrentLogFileName")
    public String clearCurrentLogFileName() {
        signLogService.clearCurrentLogFileName();
        return "success";
    }

}
